#!/usr/bin/python3
# -*- coding: utf-8; tab-width: 4; indent-tabs-mode: t -*-


class NetIfPool:

    def __init__(self):
        self._netIfDict = {}

    def getAvaliableNetIfList(self):
        return [ifname for ifname, in_use in self._netIfDict.items() if not in_use]

    def testNetIf(self, ifname):
        return self._netIfDict[ifname]

    def useNetIf(self, ifname):
        assert not self._netIfDict[ifname]
        self._netIfDict[ifname] = True

    def releaseNetIf(self, ifname):
        assert self._netIfDict[ifname]
        self._netIfDict[ifname] = False
